/*Read&write browser cookie file need these motheds*/
function esc(str){
	if(!str){
		return "";
	}
	else{
		return encodeURIComponent(str);
	} 
}
function unesc(str){
	if(!str){
		return "";
	}
	else{
		return decodeURIComponent(str);
	} 
}

function setCookie(name,value){
	document.cookie=name+"="+esc(value)+";path=/;";
}

function setDiskCookie(name,value){
	var expire=new Date();
	expire.setTime(expire.getTime()+(24*60*60*1000));
	document.cookie=name+"="+esc(value)+";expires="+expire.toGMTString()+";path=/;";
}

function getCookie(name){
	var value=null;
	var search=name+"=";
	offset=document.cookie.indexOf(search);
	if(offset!=-1){
	offset+=search.length;
	end=document.cookie.indexOf(";",offset);
	if(end==-1)end=document.cookie.length;
		value=document.cookie.substring(offset,end);
	}
	if(value==null||value=="null")value="";
	return unesc(value);
}

function getCookieSet(name){
	var cookieValue=document.cookie.split(";");
	var values="";
	for(var i=0;i<cookieValue.length;i++){
		idx=cookieValue[i].indexOf(name);
		if(idx==1&&(cookieValue[i].indexOf(name+"=")<0)&&(cookieValue[i].indexOf("="+name)<0))
			values+=cookieValue[i].substring(idx,cookieValue[i].length)+";";
	}
	return unesc(values);
}

function delCookie(name){
	var expire=new Date();
	expire.setTime(expire.getTime()-(24*60*60*1000));
	document.cookie=name+"="+esc("")+";expires="+expire.toGMTString()+";path=/;";
}

document.write("<link href='"+appRoot+"css/style.css' type=text/css rel=stylesheet>");
/*Read the theme config from user cookie*/
var stylefile = "red";
var frameColor = "#DE3A41";
if(document.cookie){
	var skinName = getCookie("userskin");
	if(skinName != "" && skinName != null){
		stylefile = skinName;
		if(skinName == "red")frameColor = "#DE3A41";
		if(skinName == "gray")frameColor = "#7E7E7E";
		if(skinName == "blue")frameColor = "#3A62DC";
		if(skinName == "green")frameColor = "#46A848";
	}
}
document.write("<link href='"+appRoot+"css/"+stylefile+".css' type=text/css rel=stylesheet>");

